public class test04 {
    class Solution {
        public List<Integer> partitionLabels(String s) {
            List<Integer> res = new ArrayList<>();
            char[] ch = s.toCharArray();
            int[] record = new int[26];//26个字母
            for(int i = 0;i<s.length();i++){
                record[s.charAt(i)-'a'] = i;
            }

            int index = 0;
            int last = -1;
            for(int i = 0;i<ch.length;i++){
                index = Math.max(index,record[ch[i]-'a']);
                if(index==i){
                    res.add(index-last);
                    last = i;
                }
            }
            return res;
        }
    }
}
